package com.zh.config;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;
//servlet容器启动的配置类，加载spring/springmvc的配置类

public class ServletContainerInitConfig extends AbstractDispatcherServletInitializer {
    //加载springmvc容器
    @Override
    protected WebApplicationContext createServletApplicationContext() {
        AnnotationConfigWebApplicationContext annotationConfigWebApplicationContext = new AnnotationConfigWebApplicationContext();
        annotationConfigWebApplicationContext.register(springMvcConfig.class);
        return annotationConfigWebApplicationContext;
    }
    //设置springmvc所处理请求路径
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }
    //加载spring容器
    @Override
    protected WebApplicationContext createRootApplicationContext() {
        return null;
    }
}
